<style>
    .layui-top-box {padding:40px 20px 20px 20px;color:#fff}
    .panel {margin-bottom:17px;background-color:#fff;border:1px solid transparent;border-radius:3px;-webkit-box-shadow:0 1px 1px rgba(0,0,0,.05);box-shadow:0 1px 1px rgba(0,0,0,.05)}
    .panel-body {padding:15px}
    .panel-title {margin-top:0;margin-bottom:0;font-size:14px;color:inherit}
    .label {display:inline;padding:.2em .6em .3em;font-size:75%;font-weight:700;line-height:1;color:#fff;text-align:center;white-space:nowrap;vertical-align:baseline;border-radius:.25em;margin-top: .3em;}
    .layui-red {color:red}
    .main_btn > p {height:40px;}
</style>
<div class="layuimini-container layuimini-page-anim">
    <!-- <div class="layuimini-main layui-top-box">
        <div class="layui-row layui-col-space10">

            <div class="layui-col-md3">
                <div class="col-xs-6 col-md-3">
                    <div class="panel layui-bg-cyan">
                        <div class="panel-body">
                            <div class="panel-title">
                                <span class="label pull-right layui-bg-blue">实时</span>
                                <h5>用户统计</h5>
                            </div>
                            <div class="panel-content">
                                <h1 class="no-margins">1234</h1>
                                <div class="stat-percent font-bold text-gray"><i class="fa fa-commenting"></i> 1234</div>
                                <small>当前分类总记录数</small>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="layui-col-md3">
                <div class="col-xs-6 col-md-3">
                    <div class="panel layui-bg-blue">
                        <div class="panel-body">
                            <div class="panel-title">
                                <span class="label pull-right layui-bg-cyan">实时</span>
                                <h5>商品统计</h5>
                            </div>
                            <div class="panel-content">
                                <h1 class="no-margins">1234</h1>
                                <div class="stat-percent font-bold text-gray"><i class="fa fa-commenting"></i> 1234</div>
                                <small>当前分类总记录数</small>
                            </div>
                        </div>
                    </div>
                </div>
            </div>

            <div class="layui-col-md3">
                <div class="col-xs-6 col-md-3">
                    <div class="panel layui-bg-green">
                        <div class="panel-body">
                            <div class="panel-title">
                                <span class="label pull-right layui-bg-orange">实时</span>
                                <h5>浏览统计</h5>
                            </div>
                            <div class="panel-content">
                                <h1 class="no-margins">1234</h1>
                                <div class="stat-percent font-bold text-gray"><i class="fa fa-commenting"></i> 1234</div>
                                <small>当前分类总记录数</small>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-col-md3">
                <div class="col-xs-6 col-md-3">
                    <div class="panel layui-bg-orange">
                        <div class="panel-body">
                            <div class="panel-title">
                                <span class="label pull-right layui-bg-green">实时</span>
                                <h5>订单统计</h5>
                            </div>
                            <div class="panel-content">
                                <h1 class="no-margins">1234</h1>
                                <div class="stat-percent font-bold text-gray"><i class="fa fa-commenting"></i> 1234</div>
                                <small>当前分类总记录数</small>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div> -->

    <div class="layui-box">
        <div class="layui-row layui-col-space10">
            <div class="layui-col-md12">
                <div class="layui-col-xs12 layui-col-md6">
                    <div id="echarts-pies" style="background-color:#ffffff;min-height:800px;padding: 10px"></div>
                </div>
                <div class="layui-col-xs12 layui-col-md6">
                    <div id="echarts-map" style="background-color:#ffffff;min-height:800px;padding: 10px"></div>
                </div>
                           
            </div>
        </div>
    </div>
</div>

<script>
    layui.use(['layer','echarts'], function () {
    var $ = layui.jquery,
        layer = layui.layer,
        echarts = layui.echarts;

        


        /**
        * 玫瑰图表
        */
        var echartsPies = echarts.init(document.getElementById('echarts-pies'), 'walden');
        $.ajax({
            type: "GET",
            url: "http://localhost:8081/analyze/chance",
            data: null,
            //dataType: "json",
            success: function (data) {

                console.log(data)
                var optionPies = {
                        title: {
                            text: '各年龄段消费占比',
                            left: 'center'
                        },
                        tooltip: {
                            trigger: 'item',
                            formatter: '{a} <br/>{b} : {c} ({d}%)'
                        },
                        legend: {
                            orient: 'vertical',
                            left: 'left',
                            data: [data[0].name, data[1].name, data[2].name, data[3].name]
                        },
                        series: [
                            {
                                name: '访问来源',
                                type: 'pie',
                                radius: '55%',
                                center: ['50%', '60%'],
                                roseType: 'radius',
                                data: data,
                                // [
                                //     {value: 335, name: '直接访问'},
                                //     {value: 310, name: '邮件营销'},
                                //     {value: 234, name: '联盟广告'},
                                //     {value: 135, name: '视频广告'},
                                //     {value: 368, name: '搜索引擎'}
                                // ],
                                emphasis: {
                                    itemStyle: {
                                        shadowBlur: 10,
                                        shadowOffsetX: 0,
                                        shadowColor: 'rgba(0, 0, 0, 0.5)'
                                    }
                                }
                            }
                        ]
                        };
                        echartsPies.setOption(optionPies);
            }
        });
        
        


        /**
         * 饼状图
         */
        var echartsMap = echarts.init(document.getElementById('echarts-map'), 'walden');

        $.ajax({
            type: "GET",
            url: "http://localhost:8080/product/foutTable",
            data: null,
            //dataType: "json",
            success: function (data) {
                //console.log(data)
                var optionMap = {
                title: {
                    text:'四季度最受欢迎的品牌占比',
                    left: 'bottom'
                },
                
                legend: {},
                tooltip: {
                    trigger: 'axis',
                    showContent: false
                },
                dataset: {
                    source: data
                    // [
                    //     ['product', '一季度', '2013', '2014', '2015'],
                    //     ['Matcha Latte', 41.1, 30.4, 65.1, 53.3],
                    //     ['Milk Tea', 86.5, 92.1, 85.7, 83.1],
                    //     ['Cheese Cocoa', 24.1, 67.2, 79.5, 86.4],
                    //     ['Walnut Brownie', 55.2, 67.1, 69.2, 72.4]
                    // ]
                },
                xAxis: {type: 'category'},
                yAxis: {gridIndex: 0},
                grid: {top: '55%'},
                series: [
                    {type: 'line', smooth: true, seriesLayoutBy: 'row'},
                    {type: 'line', smooth: true, seriesLayoutBy: 'row'},
                    {type: 'line', smooth: true, seriesLayoutBy: 'row'},
                    {type: 'line', smooth: true, seriesLayoutBy: 'row'},
                    {
                        type: 'pie',
                        id: 'pie',
                        radius: '30%',
                        center: ['50%', '25%'],
                        label: {
                            formatter: '{b}: {@第一季度} ({d}%)'
                        },
                        encode: {
                            itemName: 'product',
                            value: '第一季度',
                            tooltip: '第一季度'
                        }
                    }
                ]
            };

            echartsMap.setOption(optionMap);

            }
        });
        



        // echarts 窗口缩放自适应
        window.onresize = function () {
            echartsRecords.resize();
        }

    });    
</script>

